package com.ftg.learn.chapter09.listtest;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * 计算List中的元素和
 *
 * @author lijiaxin
 * @version 1.0
 * @date 2023/8/16 10:07
 */

public class sum1 {

    public static void main(String[] args) {

        List<Integer> numbers=new ArrayList<>();
        System.out.println("输入数字的个数");
        Scanner scanner=new Scanner(System.in);
        int count=scanner.nextInt();
        int number;
        for (int i = 0; i < count; i++) {
            System.out.println("输入数字");
            number=scanner.nextInt();
            numbers.add(number);
        }
        int sum=0;
        for (int i:numbers){
            sum+=i;
        }
        System.out.println("和"+ sum);
    }
}
